<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Overtrue\PHPLint\Linter;

class LintCommand extends Command
{
    /**
     * 命令行执行命令
     *
     * @var string
     */
    protected $signature = 'code:lint';

    /**
     * 命令描述
     *
     * @var string
     */
    protected $description = 'PHP Code Lint';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $path = base_path();
        $exclude = ['vendor'];
        $extensions = ['php'];
        $linter = new Linter($path, $exclude, $extensions);
        $errors = $linter->lint();
        if (!blank($errors)) {
            dump($errors);
        } else {
            $this->info('Lint Command Finished! No Error!');
        }
    }

}